<?php
/**
 * Created by PhpStorm.
 * User: zhaobl
 * Date: 2017\11\9 0009
 * Time: 15:53
 */

namespace System;

use Think\Route;

class Controller
{
    public function __construct()
    {
        $smarty_file = SYSTEM_PATH.'Smarty/Smarty.class.php';
        if($smarty_file){
            include_once $smarty_file;
            Loader::load_class('View',new \Smarty);
        }

        if(Loader::$load_class_arr){
            foreach(Loader::$load_class_arr as $k=>$v){
                $this->$k = $v;
            }
        }
    }


    protected function assign($name,$value='') {
        $this->View->assign($name,$value);
    }

    protected function display($templateFile='') {
        $templateFile = $templateFile ? : Loader::$load_class_arr['Router']->class.'/'.Loader::$load_class_arr['Router']->action.'.html';
        $this->View->display($templateFile);
    }


    protected function ajaxReturn($data) {
        header('Content-Type:application/json; charset=utf-8');
        exit(json_encode($data));
    }


    protected function Model($name = '')
    {
        return Model::instance($name);
    }

    public function __call($name, $arguments)
    {
        // TODO: Implement __call() method.
        echo $name;exit;

    }

}